<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/common/default.jsp"%>
<!DOCTYPE html>
<!DOCTYPE html>
<html lang="en">
<head>
    <jsp:include page="/style/header.jsp"></jsp:include>
</head>
<!-- header end -->

<body>
    <div class="title_bar">
        <h3>零星用工申请</h3>
        <a href="javascript:history.go(-1);" class="go_back"></a>
    </div>
    <div class="apply">
        <div class="ipt_title">基本信息</div>
        <div class="ipt_list">
        	<div class="ipt_cell">
                <span class="tag">签证编号</span>
                <span>${employApply.visaCode}&nbsp;</span>
            </div>
            
            <div class="ipt_cell">
                <span class="tag">项目名称</span>
                <span>${employApply.project.name}</span>
            </div>
            <div class="ipt_cell">
                <span class="tag">里程桩号</span>
                <span>${employApply.mileageCode}</span>
            </div>
            <div class="ipt_cell">
                <span class="tag">用工内容</span>
                <span>${employApply.applyContent}</span>
            </div>
            
            <div class="ipt_cell">
                <span class="tag">工程类别</span>
                <c:choose>
                	<c:when test="${employApply.projectId==1}">路基</c:when>
                	<c:when test="${employApply.projectId==2}">路面</c:when>
                	<c:when test="${employApply.projectId==3}">桥涵</c:when>
                	<c:when test="${employApply.projectId==4}">隧道</c:when>
                	<c:when test="${employApply.projectId==5}">其他</c:when>
                </c:choose>
            </div>
            
            <div class="ipt_cell">
                <span class="tag">工程量</span>
                <span>${employApply.quantities}</span>&nbsp;
            </div>
            <div class="ipt_cell">
                <span class="tag">施工队</span>${teamResult.data.name}&nbsp;
            </div>
            <div class="ipt_cell">
                <span class="tag">施工人员</span>
                <span>${employApply.onstructionPerson}</span>
            </div>
            <div class="ipt_cell">
                <span class="tag">施工工时</span>
                <span>${employApply.onstructionHour}</span>
            </div>
            <div class="ipt_cell">
                <span class="tag">工时单价</span>
                <input type="text" value="${employApply.hourPrice}" id="hourPrice" name="hourPrice">
            </div>
            <div class="ipt_cell">
                <span class="tag">费用</span>
                <span>${employApply.fee}</span>
            </div>
            
            <div class="ipt_cell mui-radio">
                <span class="tag">是否合同外？</span>
                <c:choose>
			       <c:when test="${employApply.isPlan == 1}">
			          <span>是</span>   
			       </c:when>
			       <c:otherwise>
			            <span>否</span>
			       </c:otherwise>
				</c:choose>
            </div>
            
                        
            <div class="ipt_cell">
                <span class="tag">状态</span>
                <c:choose><c:when test="${employApply.state==0}">已发起&nbsp;</c:when>
                <c:when test="${employApply.state==4}">工段已审批&nbsp;</c:when>
                <c:when test="${employApply.state==5}">合同部已审批&nbsp;</c:when>
                <c:when test="${employApply.state==6}">已完成&nbsp;</c:when>
                <c:when test="${employApply.state==-4}">工段退回&nbsp;</c:when>
                <c:when test="${employApply.state==-5}">合同部已取消&nbsp;</c:when>
                <c:otherwise>&nbsp;</c:otherwise>
                </c:choose> 
            </div>
            <div class="ipt_cell">
                <span class="tag">申请人</span>${applyUser.userName}&nbsp;
            </div>

            <div class="ipt_cell">
                <span class="tag">申请时间</span>
                <fmt:formatDate value="${employApply.applyTime}" type="both" pattern="yyyy-MM-dd HH:mm"/>&nbsp;
            </div>
            
           <div class="ipt_cell" style="border: none;">
                <span class="tag">附加照片</span>
                <div class="tip">前、中、后三张</div>
            </div>
            <!--<div class="img_upload"><span class="add_img"><img src="${ctx}/style/images/img_upload.png" alt=""></span><span class="add_img"><img src="${ctx}/style/images/img_upload.png" alt=""></span><span class="add_img"><img src="${ctx}/style/images/img_upload.png" alt=""></span></div>-->
            <div class="img_upload">
            	<c:forEach var="pic" items="${picList}">
            	<span class="add_img"><img data-preview-src="" data-preview-group="1" src="${ctx}${pic.pictureUrl}" alt="" height="130px"></span>
            	</c:forEach>
            </div>
            
            
        </div>
         
        <input type="hidden" name="totle" id ="totle" value="0" >
        <div class="ipt_title">工时信息</div>
        
        <c:forEach var="res" items="${employHourlist}">
        <div class="ipt_list hour_cell">
            <div class="ipt_cell">
                <span class="tag">施工人员</span>${res.persons}&nbsp;   
            </div>
            <div class="ipt_cell">
                <span class="tag">人数</span>${res.personNumber}&nbsp;   
               
            </div>
            <div class="ipt_cell">
                <span class="tag">起始时间</span><fmt:formatDate value="${res.startTime}" pattern="yyyy-MM-dd HH"/>&nbsp;
                
            </div>
            <div class="ipt_cell">
                <span class="tag">结束时间</span><fmt:formatDate value="${res.endTime}" pattern="yyyy-MM-dd HH"/>&nbsp;
                
            </div>
            <div class="ipt_cell">
                <span class="tag">扣除工时</span>${res.deductHour}&nbsp;
            </div>
            <div class="ipt_cell">
                <span class="tag">工时</span>${res.hours}
            </div>
       </div>
       </c:forEach>
       
       <div class="ipt_title">审批详情</div>
       
       <c:forEach var="list" items="${examineList}">
     	<div class="ipt_list hour_cell">
	     	<div class="ipt_cell">
	                <span class="tag">审批人:</span>${list.examineName}&nbsp;
	        </div>
	     	<div class="ipt_cell">
	                <span class="tag">审批时间:</span><fmt:formatDate value="${list.examineTime}" type="both" pattern="yyyy-MM-dd HH:mm"/>&nbsp;
	        </div>
	        <div class="ipt_cell">
	                <span class="tag">审批内容:</span>${list.content}&nbsp;
	        </div>
	        <div class="ipt_cell">
	                <span class="tag">备注:</span>${list.examineRemark}&nbsp;
	        </div>
        </div>
        </c:forEach>
        
       <c:choose>
      		<c:when test="${currentUser.roleId eq 4 && employApply.state==0}">
      			<div class="ipt_title">审批备注</div>
        		<div class="ipt_list">
        		<div class="ipt_cell">
	                <span class="tag">备注:</span>
	                <input type="text" placeholder="可填写备注说明" id="approveRemark">
	        	</div>
	        	</div>
	        	
            	<div class="btn_box">
            		<div class="btn" id="approve" data-type="1" data-status="4">同 意</div>
            		<div class="btn btn3" id="noapprove" data-type="1" data-status="-4">不同意</div>
            	</div> 
            </c:when>	
            <c:when test="${currentUser.roleId eq 5 && employApply.state==4}">
            	<div class="ipt_title">审批备注</div>
        		<div class="ipt_list">
        		<div class="ipt_cell">
	                <span class="tag">备注:</span>
	                <input type="text" placeholder="可填写备注说明" id="approveRemark">
	        	</div>
	        	</div>
	        	
            	<div class="btn_box">
            		<div class="btn" id="approve" data-type="1" data-status="5">同 意</div>
            		<div class="btn btn3" id="noapprove" data-type="1" data-status="-5">不同意</div>
            	</div> 
            </c:when>
            <c:when test="${currentUser.roleId eq 6 && employApply.state==5}">
            	<div class="ipt_title">审批备注</div>
        		<div class="ipt_list">
        		<div class="ipt_cell">
	                <span class="tag">备注:</span>
	                <input type="text" placeholder="可填写备注说明" id="approveRemark">
	        	</div>
	        	</div>
	        	
            	<div class="btn_box"><div class="btn" id="approve" data-type="1" data-status="6">同 意</div>
            	<div class="btn btn3" id="noapprove" data-type="1" data-status="-6">不同意</div></div> 
            </c:when>
    </c:choose>
    
    <c:if test="${user.roleId eq 2  && (res.state==0||res.state==3||res.state==4||res.state==5)}">
     	<div class="ipt_title">当前审批人</div>
     	<div class="ipt_list hour_cell">
	     	<div class="ipt_cell">
	                <span class="tag">审批人:</span>${nextApprovUser.userName}&nbsp;
	        </div>
	     	<div class="ipt_cell">
	                <span class="tag">电话:</span>${nextApprovUser.phoneNum}&nbsp;
	        </div>
	       
       	</div>
     	</div>
     </c:if>
    </div><br/>
    
    <!-- footer start -->
    <jsp:include page="/style/footer.jsp"></jsp:include>
    <script>
    $('#approve').click(function() { 
    	var status = jQuery("#approve").data('status');
   	 	var type = jQuery("#approve").data('type');
   	 	var approveRemark = jQuery("#approveRemark").val();
   	    var hourPrice = jQuery("#hourPrice").val();
   	 	var approve_data = {
     		'applyType': type,
     		'status':status,
     		'applyId':"${employApply.applyId}",
     		'approveUserId':"${currentUser.user_id}",
     		'approveLoginName':"${currentUser.loginName}",
     		'approveUserName':"${currentUser.userName}",
     		'approveRemark':approveRemark,
    		'price':hourPrice
        }
   	    loading_show(); 
   	 	$.ajax({
	        async: true,
	        type:"POST",
	        data:JSON.stringify(approve_data),
	        
	        url: "${ctx}/approve/todo?mid="+Math.random(),
	        dataType: "json",
	        headers : {  
         	'Content-Type' : 'application/json;charset=utf-8'  
         },
           
         success : function(data) {
        	loading_hide(500);
       		if (data != undefined && data.status != undefined
       				&& data.status.trim() == '0') {
       			window.location.href = "${ctx}/approve/success";
       			tiper(data.error,'green');
       			result = true;
       		} else {
       			result = false;
       			tiper(data.error);
       		}
       	},
		},"json")
    });
    
    $('#noapprove').click(function() { 
    	var status = jQuery("#noapprove").data('status');
   	 	var type = jQuery("#noapprove").data('type');
   	 	var approveRemark = jQuery("#approveRemark").val();
	    var hourPrice = jQuery("#hourPrice").val();
   	 	var approve_data = {
     		'applyType': type,
     		'status':status,
     		'applyId':"${employApply.applyId}",
     		'approveUserId':"${currentUser.user_id}",
     		'approveLoginName':"${currentUser.loginName}",
     		'approveUserName':"${currentUser.userName}",
     		'approveRemark':approveRemark,
    		'price':hourPrice
        }
   	 	$.ajax({
	        async: true,
	        type:"POST",
	        data:JSON.stringify(approve_data),
	        
	        url: "${ctx}/approve/todo?mid="+Math.random(),
	        dataType: "json",
	        headers : {  
         	'Content-Type' : 'application/json;charset=utf-8'  
         },
           
         success : function(data) {
       		if (data != undefined && data.status != undefined
       				&& data.status.trim() == '0') {
       			window.location.href = "${ctx}/approve/success";
       			tiper(data.error,'green');
       			result = true;
       		} else {
       			result = false;
       			tiper(data.error);
       		}
       	},
		},"json")
    });
    
    $('input').prop('disabled', true);
    $('#approveRemark').prop('disabled', false);
    if(${currentUser.roleId}==5){
   		$('#hourPrice').prop('disabled', false);
    }
    mui.previewImage();
    </script>
</body>

</html>
